const CourseModel = require('../db/models/course');

class CourseService {
    async getCollectionCourseData (idList) {
        return await CourseModel.findAll({
            raw: true,
            where: {
                // id: [1, 2, 3]//注意这里是可以直接写一个数组的，查出来的也是符合数组里面的条件的所有数据
                cid: idList
            },
            attributes: {
                exclude: ['cid', 'posterUrl', 'field', 'createdAt', 'updatedAt']
            }
        })
    }

    async getCourseData () {
        return await CourseModel.findAll({
            where: {
                status: 1
            },
            order: [
                ['id', 'DESC']
            ],
            attributes: {
                exclude: ['cid', 'posterUrl', 'createdAt', 'updatedAt']
            }
        });
    }
}

module.exports = new CourseService();